package com.trinity.task;

import com.trinity.common.core.domain.dto.StudentUser;
import com.trinity.common.core.domain.entity.SysUser;
import com.trinity.system.service.ISysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 */
@Slf4j
@Component
public class UserTask {
    @Resource
    private ISysUserService userService;

    /**
     * 更新用户信息
     */
    public void updateUser() {
        log.info("定时任务开启：-----------------------------------");
        log.info("-----------------------------------------------");
        log.info("------------------更新用户信息-------------------");
        log.info("-----------------------------------------------");
        log.info("-----------------------------------------------");
        List<StudentUser> studentUsers = userService.selectStudentUserInfo();
        for (StudentUser user : studentUsers) {
            log.info("-------------------{}---------------------", user.getUserId());
            log.info("-------------------{}---------------------", user.getStudentName());
            SysUser sysUser = new SysUser();
            sysUser.setUserId(user.getUserId());
            sysUser.setNickName(user.getStudentName());
            //学校部门
            sysUser.setDeptId(user.getSchoolDeptId());
            userService.updateUser(sysUser);
        }
        log.info("定时任务结束：-----------------------------------");
        log.info("-----------------------------------------------");
        log.info("-----------------------------------------------");
        log.info("-----------------------------------------------");
        log.info("-----------------------------------------------");

    }

}
